package com.cqsw.bbs.controller;

import com.cqsw.bbs.entity.Forum;
import com.cqsw.bbs.entity.User;
import com.cqsw.bbs.service.ForumService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @author: ZackYoung
 * @time: 2020/6/15
 */
@Controller
@RequestMapping("user/control/topic")
public class TopicController {
    @Autowired
    private ForumService forumService;
    @RequestMapping("/add")
    @ResponseBody
    public Map  add(Integer tagId, String title, String content, HttpServletRequest req){
        User user = (User) req.getSession().getAttribute("userList");
        Forum forum = new Forum();
        forum.setUserId(user.getId());
        forum.setContent(content);

        forum.setTagId(tagId);

        forum.setTitle(title);
        Map map = forumService.insertForum(forum);
        return map;
    }
}
